home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Online / LineShare 3.3.1 / LineShare Scripts / Generic ARA&Data < prev    next >
Text File  |  1995-01-03  |  6KB  |  314 lines

  1. ! Version 3.1.0
  2. !
  3. !$ Use this script with ARA 1.0 or 2.0,
  4. !$ and a BBS, E-mail or other communication server software
  5. !
  6. !$ A cable for hardware handshaking is required
  7.  
  8. ^2 HW handshake AT-cmd: = Text "&K3&D2"
  9. ^3 Normal Link AT-cmd: = Text "\N0"
  10. ^4 Auto-Rel Link AT-cmd: = Text "\N3"
  11. ^5 Link Speed AT-cmd: = Text "W1"
  12. ^6 Error Correction for ARA: = Bool("Enabled"="1","Disabled"="0") "0"
  13. ^7 Answer On: = Enum("Never"="0","1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  14. ^8 Data Port Speed: = Enum("9600","19200","38400","57600") "19200"
  15. ! ------------------------------------------
  16. ! Resetting the modem:
  17. ! ------------------------------------------
  18. @Hangup
  19.   SetTries 2
  20.   Flush
  21.   HsReset 0,0,0,0,0,0
  22. !
  23. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  24. ! to enter the command mode
  25. !
  26. @Label 1
  27.   matchclr
  28.   matchstr 1 2 "OK\r\n"
  29.   write "ATH0V1Q0\r"
  30.   matchread 20
  31.   ChrDelay 1
  32.   Write "+++"
  33.   ChrDelay 0
  34.   DtrClear
  35.   SBreak
  36.   DtrSet
  37. !
  38.   DecTries
  39.   IfTries 0 1
  40. !
  41. ! OSErr -6019 "Modem error - the modem is not responding"
  42. !
  43.   exit -6019
  44. @Label 2
  45.   Write "AT&F\r"
  46.   Jsr 100
  47.   exit 0
  48.  
  49. ! ------------------------------------------
  50. !    Receiving incoming calls
  51. ! ------------------------------------------
  52. @ANSWER
  53. @Label 10
  54. !
  55. ! Set the modem preferred speed first
  56.   SerReset Val("^8"),0,8,1
  57.   Jsr 80
  58. !
  59. ! Set the common options
  60.   Jsr 70
  61. !
  62. ! Set the communication options:
  63. ! • Normal/AUTO Connection
  64. ! • HW flow control
  65. ! • CONNECT <DCE speed> or CARRIER/CONNECT
  66. !
  67.   SetVar A "^3"
  68.   IfStr 6 11 "0"
  69.   SetVar A "^4"
  70. @Label 11
  71.   Write "AT^2^A^5\r"
  72.   Jsr 100
  73. !
  74. ! Get the Speaker and the Ring Num options
  75.   GetCommand B "Data" "M"
  76.   GetCommand C "Data" "L"
  77.   SetVar A "S0=^7"
  78. !
  79. ! Fetch the tube after <A> rings, <B><C> - speaker options
  80.   Write "AT^A^B^C\r"
  81.   Jsr 100
  82. !
  83. ! Everything is ready - let's sit and wait for a call
  84. ! We'll wait for 2 minutes, then reinitiate the modem
  85.   Note "Waiting for a ARA or Data call…"
  86.   Jsr 90
  87.   IfStr D 20 "DATA"
  88.   Jump 10
  89.  
  90. !
  91. ! Data connection has been established (we read "CONNECT")
  92. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  93. ! if it was an incoming call, put the "RING" before the "CONNECT"
  94. !
  95. @Label 20
  96.   IfOpen "Data" 21
  97.   Jump 30
  98. @Label 21
  99.   IfOpen "ARA" 22
  100.   Jump 35
  101. @Label 22
  102.   Note "Waiting for an ARA frame"
  103.   MatchClr
  104.   MatchStr 1 23 "^$\r"
  105.   MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
  106.   MatchStr 3 29 "\01\27\02\29\01\02\01\06"
  107.   MatchRead 40
  108.   Jump 24
  109. @Label 23
  110.   QueueInput "^$\r"
  111. @Label 24
  112.   Note "Non-ARA call"
  113.   Jump 35
  114.  
  115. @Label 28
  116.   Note "ARA 1.0 call"
  117.   Jump 30
  118. @Label 29
  119.   Note "ARA 2.0 call"
  120.   Jump 30
  121.  
  122. @Label 30
  123.   QueueInput "\r\nCARRIER ^B\r\n"  
  124.   IfStr A 31 "NONE"
  125.   IfStr A 31 "None"
  126.   QueueInput "\r\nREL\r\n"
  127. @Label 31
  128.   IfOriginate 32
  129.   QueueInput "\r\nRING\r\n"
  130. @Label 32
  131.   Attach "ARA" (DTR)
  132.  
  133. @Label 35
  134.   GetSReg C "DATA" 4
  135.   QueueInput "\r^CCONNECT ^B\r^C"
  136.   ifOriginate 36
  137.   QueueInput "\r^CRING\r^C"
  138. @Label 36
  139.   HsReset 0,1,0,0,0,1
  140.   Attach "Data" (DTR,Escape,Break)
  141.  
  142. ! ------------------------------------------
  143. ! Originating a call through the "ARA" subport
  144. ! ------------------------------------------
  145. @ORIGINATE "ARA"
  146.   SerReset Val("^8"),0,8,1
  147.   Jsr 80
  148. !
  149. ! Set the common options
  150.   Jsr 70
  151. !
  152. ! Set the communication options:
  153. ! • HW flow control
  154. ! • Normal Connection
  155. ! • CONNECT <DCE speed> or CARRIER/CONNECT
  156. !
  157.   Write "AT^2^3^5\r"
  158.   Jsr 100
  159. !
  160. ! dial the number
  161.   Write "ATD^1\r"
  162. !
  163. ! Wait for a modem response
  164.   Jsr 90
  165.   IfStr D 30 "DATA"
  166.   Write "\r"
  167.   Exit -6019
  168.  
  169. ! ------------------------------------------
  170. ! Originating a call through the "DATA" subport
  171. ! ------------------------------------------
  172. @ORIGINATE "Data" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  173.   SerReset Val("^8"),0,8,1
  174.   Jsr 80
  175. !
  176. ! Set the common options
  177.   Jsr 70
  178. !
  179. ! Set the communication options:
  180. ! • Normal Connection
  181. ! • HW flow control
  182. ! • CONNECT <DCE speed> or CARRIER/CONNECT
  183. !
  184.   Write "AT^2^4^5\r"
  185.   Jsr 100
  186. !
  187. ! dial the number
  188.   Write "ATD^1\r"
  189.   HsReset *
  190. !
  191. ! Wait for a modem response
  192.   Jsr 90
  193.   IfStr D 35 "DATA"
  194.   Write "\r"
  195.   Exit -6019
  196.  
  197. !
  198. ! This section emits all modem commands sent from the client application
  199. ! For each set of commands the "OK" answer is awaited
  200. !
  201. @Label 60
  202.   EmitStart
  203. @Label 61
  204.   EmitCommand 62
  205.   Jsr 100
  206.   Jump 61
  207. @Label 62
  208.   return
  209. !
  210. ! This section initiates the modem before ANSWER and ORIGINATEs:
  211. ! reset on Dtr drop + DCD valid
  212. ! Verbal responses mode, no echo 
  213. !
  214. @Label 70
  215.   Write "AT&C1V1E0\r"
  216.   Jsr 100
  217.   return 
  218.  
  219. !
  220. ! This section syncronize the modem after the serial port speed switching
  221. !
  222. @Label 80
  223.   ChrDelay 1
  224.   Write "AT\r"
  225.   ChrDelay 0
  226.   Jsr 100
  227.   return
  228. !
  229. ! Error codes
  230. @Label 81
  231.   exit -6020
  232. @Label 82
  233.   exit -6022
  234. @Label 83
  235.   exit -6021
  236. @Label 84
  237.   exit -6023
  238.   
  239. !
  240. ! This subroutine waits for the modem response
  241. ! On exit, ^D contains the result code: "DATA" or "NONE"
  242. ! ^A contains the protocol used
  243. ! ^B contains the carrier speed
  244. ! If modem reports an error, the scripts exits with an error code
  245. !
  246. @Label 89
  247.   Note "Ring…"
  248.   Jump 91
  249.  
  250. @Label 90
  251.   SetVar A "NONE"
  252.   SetVar B ""
  253.   MatchClr
  254.   Matchstr 1 92 "CARRIER ^$\r\n"
  255.   Matchstr 2 93 "PROTOCOL: ^$\r\n"
  256.  
  257.   Matchstr 4 95 "CONNECT ^$/"
  258.   Matchstr 5 97 "CONNECT ^$\r\n"
  259.   Matchstr 6 89 "RING\r\n"
  260.   Matchstr 10 82 "BUSY\r\n"
  261.   MatchStr 11 83 "NO CARRIER\r\n"
  262.   MatchStr 12 84 "NO ANSWER\r\n"
  263.   MatchStr 13 81 "NO DIALTONE\r\n"
  264. @Label 91
  265.   Matchread 1200
  266.   SetVar D "NONE"
  267.   return
  268.  
  269. @Label 92
  270.   SetVar B "^$"
  271.   Jump 91
  272. @Label 93
  273.   SetVar A "^$"
  274.   Jump 91
  275.  
  276. ! CONNECT xxxx/XXXX was detected
  277. @Label 95
  278.   Jsr 98
  279.   MatchClr
  280.   MatchStr 1 96 "^$\r\n"
  281.   MatchRead 10
  282. @Label 96
  283.   SetVar A "^$"
  284.   SetVar D "DATA"
  285.   return
  286.  
  287. ! CONNECT xxx was detected
  288. @Label 97
  289.   Jsr 98
  290.   SetVar D "DATA"
  291.   return
  292.  
  293. @Label 98
  294.   ifStr B 99 ""
  295.   return
  296. @Label 99
  297.   SetVar B "^$"
  298.   return 
  299. !
  300. ! Processing the AT command:
  301. ! OK -> proceed
  302. ! ERROR or TimeOut ->exit -6019
  303. ! It can be called AFTER the "Write" command, since LineShare buffers input
  304. !
  305. @Label 100
  306.   MatchClr
  307.   MatchStr 1 102 "OK\r\n"
  308.   MatchStr 2 101 "ERROR\r\n"
  309.   MatchRead 20
  310. @Label 101
  311.   Exit -6019
  312. @Label 102
  313.   return
  314.